package com.demo.listener;

import com.demo.MqConstants;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * topic需要和生产者的topic一致，consumerGroup属性是必须指定的，内容可以随意
 * @author shenguangyang
 */
@Component
@RocketMQMessageListener(
        nameServer = "${rocketmq.name-server}",
        topic = MqConstants.EMAIL_TOPIC,
        consumerGroup = MqConstants.EMAIL_WITH_TAG_CONSUME_GROUP, selectorExpression = MqConstants.EMAIL_TAG)
public class EmailWithTagListener implements RocketMQListener<EmailMessage> {
    private static final Logger log = LoggerFactory.getLogger(EmailWithTagListener.class);
    @Override
    public void onMessage(EmailMessage emailMessage) {
        log.info(emailMessage.toString());
    }
}
